package com.yun.controller;

import com.yun.dao.db.DbDoctor;
import com.yun.dao.db.DbSickroom;
import com.yun.pojo.Linkage;
import com.yun.pojo.db.Doctor;

import com.yun.service.LinkageService;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.annotation.PostConstruct;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

@Controller
public class DoctorController {
    @Autowired
    DbDoctor dbDoctor;

    @Autowired
    LinkageService linkageService;

    @RequestMapping(value = "/getDoctors",method = RequestMethod.GET)
    public String getDoctors(Model model) {
        Collection<Doctor> doctor = dbDoctor.getDoctor();
        model.addAttribute("list", doctor);
        return "doctor/doctorList";
    }

    @RequestMapping("/selectDoctor/{p}")
    @ResponseBody
    public List<Linkage> selectDoctor(@PathVariable("p") String room){
        List<Linkage> doctorList = linkageService.selectDoctor(room);
        return doctorList ;
    }
}
